faApp.controller('BankListCtrl',['$scope','withdrawService','$location','$controller','$route',function($scope,withdrawService,$location,$controller,$route) {   
	$controller('BaseCtrl', {$scope: $scope}); 

}]);

faApp.controller('WithdrawListCtrl',['$scope','withdrawService','$location','$controller','$route',function($scope,withdrawService,$location,$controller,$route) {   
	$controller('BaseCtrl', {$scope: $scope}); 

  $scope.list = [];

	$scope.$watch('config',function(){
    withdrawService.withdrawList($scope.config).then(function(json){
      $scope.list = json.list || [];
      $scope.pager = json.pager;
    });
  },true);

	$scope.config = {
		"pageSize" : 20,
		"pageNo" : 1,
		"loginName" : '',
	};

  $scope.searchMap = {
		"loginName" : '', 
  };

  $scope.search = function(){

    angular.forEach($scope.searchMap,function(o,i){
      $scope.config[i] = ( undefined == $scope.searchMap[i] ? "" : $scope.searchMap[i]);
    });

  };
  
	$scope.pageChanged = function(){
		$scope.config.pageNo = $scope.pager.pageNo;
	};

}]);


faApp.controller('WithdrawViewCtrl',['$scope','withdrawService','$location','$controller','$route','$routeParams',function($scope,withdrawService,$location,$controller,$route,$routeParams) {   
	$controller('BaseCtrl', {$scope: $scope}); 

  $scope.id = $routeParams.id;
  $scope.item = {id:$scope.id};
  $scope.withdraw = {};

  withdrawService.withdrawQuery($scope.id).then(function(json){
    $scope.withdraw = json.dto; 
  });

  $scope.save = function(){
    if (!$scope.form.$invalid){
      withdrawService.withdrawEdit($scope.item).then(function(json){
        if (!json.statusCode){
          $scope.alertNextPage("操作成功");
          $location.path("/withdraw/list");
        }else{
          alert("出错了:" + json.statusCode);
        }  
      });
    }else{
      alert("请先完整填写信息");
      return;
    }
  };
}]);
